#include <iostream>

using namespace std;

int T;

int main()
{
	cin >> T;
	
	
	while (T -- )
	{
		string s;
		cin >> s;
		
		int n = s.size();
		
		if (s[0] >= 'a' && s[0] <= 'z') s[0] -= 32;
		
		for (int i = 1; i < n; i ++ )
		{
			if (s[i] >= 'A' && s[i] <= 'Z') s[i] += 32;
		}
		
		cout << s << endl;
	}
	
	return 0;
}
